// 验证表单
var form = layui.form

//收集信息
$(".layui-form").on("submit", function (e) {
    e.preventDefault()
    let data = $(this).serialize()
    $.ajax({
        type: "post",
        url: "/admin/users",
        data,
        success: function (res) {
            if (res.status === 0) {
                layer.msg(res.message, {
                    time: 3000
                }, function () {
                    $(".layui-form")[0].reset()
                    location.href = "./user.html"
                })
            } else if (res.status === -1) {
                layer.msg(res.message)

            }


        }
    })

})






form.verify({
    name: function () {
        let password = $("#password").val()
        let surePwd = $("#surePwd").val()
        if (password !== surePwd) {
            return "前后密码不一致哦!"
        }
    }
})